unit Class_KzAxis;

interface
uses
  Classes,ExtCtrls,StdCtrls,Windows,Controls,Messages,Menus,Graphics;

type
  TKzAxisType=(katAxisX,katAxisY);
  
  TKzAxis=class(TShape)
  public
    PosX:Integer;
    PosY:Integer;

    HRN:HRGN;
  public
    AxisType:TKzAxisType;
    ColIndex:Integer;  
  public
    procedure PrepareRegion;
    procedure OnShapeDragOver(Sender, Source: TObject; X, Y: Integer;State: TDragState; var Accept: Boolean);    
  public
    procedure WndProc(var Message: TMessage); override;  
    procedure Paint; override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

implementation

uses
  Dialogs,Forms;

{ TKzShape }

constructor TKzAxis.Create(AOwner: TComponent);
begin
  inherited;
  ControlStyle := ControlStyle + [csReplicatable];
  Height := 1;
  DragMode:=dmAutomatic;
  OnDragOver:=OnShapeDragOver;
  
  //Rgn := CreateRectRgn(0, 0, 15, 15);  
end;

destructor TKzAxis.Destroy;
begin
  DeleteObject(HRN);
  inherited;
end;

procedure TKzAxis.OnShapeDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  //if (Source is TListBox) then
  begin
    //if TListBox(Source).Tag=2 then
    begin
      Accept:=True;
    end;
  end;
end;

procedure TKzAxis.Paint;
begin
  inherited;
  
end;

procedure TKzAxis.PrepareRegion;
begin
  HRN:=CreateRectRgn(Self.BoundsRect.TopLeft.X,Self.BoundsRect.TopLeft.Y,Self.BoundsRect.BottomRight.X,Self.BoundsRect.BottomRight.Y);
end;

procedure TKzAxis.WndProc(var Message: TMessage);
begin
  if (Message.Msg = WM_SETCURSOR)  then
  begin
    if not PtInRegion(HRN, TWMMouse(Message).XPos, TWMMouse(Message).YPos) then
    begin
      ShowMessage('true');
      //ControlAtPos(SmallPointToPoint(TWMMouse(Message).Pos));
    end else
    begin
      //_Click(TWMMouse(Message).XPos, TWMMouse(Message).YPos);
    end;
  end;
  inherited;
end;

end.
